import Vue from 'vue';
import Router from 'vue-router';

import 'nprogress/nprogress.css'
import Home from '../components/common/Home'

Vue.use(Router);

//静态路由
export const constantRouterMap = [
    {
        path: '/',
        redirect: '/dashboard'
    },
    {
        path: '/dashboard',
        component: Home,
        meta: { title: '系统首页', icon: 'el-icon-setting' },
        children: [
            {
                path: '/dashboard',
                component: resolve => require(['../components/page/Dashboard.vue'], resolve),
                meta: { title: '系统首页' }
            },
        ]
    },

    {
        path: '/login',
        component: resolve => require(['../components/page/Login.vue'], resolve),
        hidden: true
    },
    {
        path: '/echart',
        component: Home,
        meta: { title: '图表', icon: 'el-icon-tickets' },
        children: [
            {
                path: 'networkLoad',
                component: resolve => require(['../components/page/charts/NetworkLoad.vue'], resolve),
                meta: { title: '网络负载' }
            },
            {
                path: 'eventClassification',
                component: resolve => require(['../components/page/charts/EventClassification.vue'], resolve),
                meta: { title: '事件分类' }
            },
            {
                path: 'serverCpuUsage',
                component: resolve => require(['../components/page/charts/ServerCpuUsage.vue'], resolve),
                meta: { title: '服务器CPU使用情况' }
            },
            {
                path: 'systemHealth',
                component: resolve => require(['../components/page/charts/SystemHealth.vue'], resolve),
                meta: { title: '系统健康值' }
            },
            {
                path: 'coreSwitchPerformance',
                component: resolve => require(['../components/page/charts/CoreSwitchPerformance.vue'], resolve),
                meta: { title: '核心交换机性能' }
            },
            {
                path: 'faultStatistics',
                component: resolve => require(['../components/page/charts/FaultStatistics.vue'], resolve),
                meta: { title: '故障统计' }
            },
            {
                path: 'OperationStatistics',
                component: resolve => require(['../components/page/charts/OperationStatistics.vue'], resolve),
                meta: { title: '各站点运维统计' }
            },
            {
                path: 'ClassificationStatistics',
                component: resolve => require(['../components/page/charts/ClassificationStatistics.vue'], resolve),
                meta: { title: '分类统计' }
            },
            {
                path: 'InterfaceState',
                component: resolve => require(['../components/page/charts/InterfaceState.vue'], resolve),
                meta: { title: '接口状态' }
            },{
                path: 'WeekWorkOrder',
                component: resolve => require(['../components/page/charts/WeekWorkOrder.vue'],resolve),
                meta:{ title:'一周工单运维统计'}
            },
            {
                path: 'WeekWorkOrder2',
                component: resolve => require(['../components/page/charts/WeekWorkOrder2.vue'],resolve),
                meta:{ title:'一周工单运维统计2'}
            },
            {
                path: 'WorkOrderPro',
                component: resolve => require(['../components/page/charts/WorkOrderPro.vue'],resolve),
                meta:{ title:'工单处理情况'}
            },
            {
                path: 'equipmentMGT',
                component: resolve => require(['../components/page/EquipmentMGT.vue'],resolve),
                meta:{ title:'设备管理'}
            }
        ]
    },
    {
        path: '/echart',
        component: Home,
        meta: { title: '设备管理', icon: 'el-icon-tickets' },
        children: [
            {
                path: 'DeviceManagement',
                component: resolve => require(['@/components/page/DeviceManagement.vue'], resolve),
                meta: { title: '设备管理' }
            }
        ]
    }       
]

//动态路由
export const asyncRouterMap = [
    {
        path: '/user',
        component: Home,
        meta: { title: '用户管理', icon: 'el-icon-tickets' },
        children: [
            {
                path: 'table',
                component: resolve => require(['../components/page/BaseTable.vue'], resolve),
                meta: { title: '用户管理', roles: ['userAdmin'] }
            }
        ]
    },
    {
        path: '/form',
        component: Home,
        meta: { title: '基本表单', icon: 'el-icon-date' },
        children: [
            {
                path: 'basicform',
                component: resolve => require(['../components/page/BaseForm.vue'], resolve),
                meta: { title: '基本表单', roles: ['operator'] }
            },
            {
                path: 'basicformss',   
                component: resolve => require(['../components/page/BaseTable.vue'], resolve),
                meta: { title: '用户管理', roles: ['average'] }
            },
            {
                path: 'PrivilegeManage',   
                component: resolve => require(['../components/page/PrivilegeManage.vue'], resolve),
                meta: { title: '权限管理', roles: ['average'] }
            },
            {
                path: 'UserPrivilegeManage',
                component: resolve =>require(['../components/page/UserPrivilegeManage.vue'], resolve),
                meta: { title: '用户权限管理',roles: ['average']} 
            }
        ]
    },
    {
        path: '/403',
        component: Home,
        name: 'Err-403',
        hidden: true,
        children: [
            {
                path: '/403',
                component: resolve => require(['../components/page/403.vue'], resolve),
                meta: { title: '403' }
            }
        ]
    },
    {
        path: '/404',
        component: Home,
        name: 'Err-404',
        hidden: true,
        children: [
            {
                path: '/404',
                component: resolve => require(['../components/page/404.vue'], resolve),
                meta: { title: '404' }
            }
        ]
    },
    {
        path: '*',
        name: 'Err',
        redirect: '/404',
        hidden: true
    }
]



const router = new Router({
    mode: 'history',
    //VUE 滚动行为
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        }
        return { x: 0, y: 0 }
    },
    routes: constantRouterMap
})


export default router
